home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / art3dPaintEffectsBrushCallba < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.2 KB  |  105 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  23 April 2001
  22. //
  23. //  Procedure Name:
  24. //      art3dPaintEffectsBrushCallback
  25. //
  26. //  Description:
  27. //      Callback that is called via a scriptJob whenever an important 
  28. //        attribute on the paint effects default brush is changed.
  29. //
  30. //  Input Arguments:
  31. //      $artCommand - command to change tool settings
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36. global proc art3dPaintEffectsBrushCallback( string $artCommand )
  37. {
  38.     // Set the paint effects brush mode.
  39.     //
  40.     string $currContext = `currentCtx`;
  41.  
  42.     if ( $currContext != "art3dPaintContext" ) return;
  43.  
  44.     // Read old values out of the context to see if we really need to update it
  45.     //
  46.     string $cmd = $artCommand + " -q -paintoperationtype " + $currContext;
  47.     string $oldOp = eval( $cmd );
  48.     $cmd = $artCommand + " -q -brushtype " + $currContext;
  49.     string $oldBrushType = eval( $cmd );
  50.     $cmd = $artCommand + " -q -pfxScale " + $currContext;
  51.     float $oldScale = eval( $cmd );
  52.     $cmd = $artCommand + " -q -pfxWidth " + $currContext;
  53.     float $oldWidth = eval( $cmd );
  54.  
  55.     // If 3D paint is not in paint effects mode, then we don't need to update 
  56.      //
  57.     if ( $oldBrushType != "effectsBrush" ) return;
  58.  
  59.     // Figure out the new values to set into the context
  60.     //
  61.     string $operation;
  62.     float $scale, $width;
  63.     
  64.     // Set the paint mode based on the brush settings
  65.     //
  66.     string $defaultBrush = getDefaultBrush();
  67.     int $mode = getAttr( $defaultBrush + ".brushType" );
  68.     switch( $mode ) {
  69.     case 0: // Paint
  70.     case 4: // ThinLine
  71.     case 5: // Mesh
  72.         $operation = "Paint";
  73.         break;
  74.     case 1: // Smear
  75.         $operation = "Smear";
  76.         break;
  77.     case 2: // Blur
  78.         $operation = "Blur";
  79.         break;
  80.     }
  81.  
  82.     $scale = getAttr( $defaultBrush + ".globalScale" );
  83.     $width = getAttr( $defaultBrush + ".brushWidth" );
  84.  
  85.     // Check to see if we need to update the context
  86.     //
  87.     if ( ( $oldOp == $operation ) &&
  88.          ( abs( $oldScale - $scale ) < 0.0001 ) &&
  89.          ( abs( $oldWidth - $width ) < 0.0001 ) )
  90.     {
  91.         // Everything's up to date
  92.         //
  93.         return;
  94.     }
  95.  
  96.     // Build and execute the command to update the context
  97.     //
  98.     $cmd = $artCommand;
  99.     $cmd += " -e -paintoperationtype \"" + $operation + "\" ";
  100.     $cmd += " -e -pfxScale " + $scale + " ";
  101.     $cmd += " -e -pfxWidth " + $width + " ";
  102.     $cmd += $currContext;
  103.  
  104.     eval $cmd;
  105. }